<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    x:Class="OpenLS.UI.Themes.GalleryResources"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:oui="clr-namespace:OpenLS.UI"
    xmlns:Internals="clr-namespace:OpenLS.UI.Internals"
    xmlns:Themes="clr-namespace:OpenLS.UI.Themes"
    >
    <ResourceDictionary.MergedDictionaries>
        <Themes:ButtonResources />
        <Themes:ContentPresenterResources />
        <Internals:HeaderPresenterControlResources />
        <Internals:ResizeThumbResources />
    </ResourceDictionary.MergedDictionaries>
    <Geometry x:Key="downArrowGeometry">M 0 0 L 4.5 6 L 9 0 Z</Geometry>



    <Geometry x:Key="downArrowGeometrybackup">M 0 0 L 2.5 3 L 5 0 Z</Geometry>
    <Style TargetType="{x:Type oui:GalleryItem}" x:Key="focusableGalleryItem">
        <Setter Property="Padding" Value="2"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type oui:GalleryItem}">
                    <Border Background="{TemplateBinding Background}" x:Name="Bd" SnapsToDevicePixels="True"
                BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                Padding="{TemplateBinding Padding}"
                      >
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" x:Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBackgroundKey}}" TargetName="Bd"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="Bd"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GalleryItemSelectedBackgroundKey}}" TargetName="Bd"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="Bd"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GalleryItemSelectedBackgroundKey}}" TargetName="Bd"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="Bd"/>

                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="oui:HighlightElement.IsHighlighted" Value="True"></Setter>
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type oui:GalleryItem}" x:Key="nonfocusableGalleryItem">
        <Setter Property="Focusable"  Value="False" />
    </Style>
    <ControlTemplate TargetType="{x:Type ScrollViewer}" x:Key="scrollViewer">
        <Border BorderThickness="1" BorderBrush="{DynamicResource {x:Static oui:OfficeBrushes.GroupBorderBrushKey}}" CornerRadius="1">
            <DockPanel>
                <DockPanel.Resources>
                    <Style TargetType="{x:Type RepeatButton}">
                        <Setter Property="Focusable" Value="False"/>
                        <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.BoxBackgroundKey}}"></Setter>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                    <Grid Background="{TemplateBinding Background}" Name="ggrid1">
                                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <Trigger Property ="IsMouseOver" Value="True">
                                <Setter Property="Background" Value ="{DynamicResource {x:Static oui:OfficeBrushes.ButtonHoverBackgroundKey}}" />
                            </Trigger>
                            <Trigger Property ="IsPressed" Value="True">
                                <Setter Property="Background" Value ="{DynamicResource {x:Static oui:OfficeBrushes.ButtonPressedBackgroundKey}}" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </DockPanel.Resources>
                <Grid SnapsToDevicePixels="True" DockPanel.Dock="Right" Width="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <RepeatButton Grid.Row="0" Command="{x:Static ScrollBar.LineUpCommand}" Margin="0 0 0 1">
                        <Path Data="M0, 0 L 6 0 L 3 -3 Z" Fill="Black"></Path>
                    </RepeatButton>
                    <RepeatButton Grid.Row="1" Command="{x:Static ScrollBar.LineDownCommand}">
                        <Path Data="M0, 0 L 6 0 L 3 3 Z" Fill="Black"></Path>
                    </RepeatButton>
                    <RepeatButton Grid.Row="2" Command="{x:Static oui:GalleryElement.Expand}" Margin="0 1 0 0">
                        <Grid>
                            <Path Data="M0, 2 L 6 2 L 3 5 Z" Fill="Black" Stroke="Black" StrokeThickness="0"></Path>
                            <Line SnapsToDevicePixels="True" X1="0" Y1="-2" X2="6" Y2="-2" Stroke="Black"  StrokeThickness="1"/>
                        </Grid>
                    </RepeatButton>
                </Grid>
                <Border Background="{TemplateBinding Background}" >
                    <ScrollContentPresenter Name="PART_ScrollContentPresenter" Content="{TemplateBinding Content}" 
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    CanContentScroll="{TemplateBinding CanContentScroll}" />
                </Border>
            </DockPanel>
        </Border>
        
    </ControlTemplate>
    <ControlTemplate TargetType="{x:Type oui:Gallery}" x:Key="normalTemplate">
        <Grid Background="{TemplateBinding Background}" Name="ggrid2">
            <ScrollViewer Template="{StaticResource scrollViewer}" 
                      HorizontalScrollBarVisibility="Disabled" 
                      Loaded="onLoaded" VerticalScrollBarVisibility="Visible"
                      Background="{TemplateBinding Background}">
                <ScrollViewer.CommandBindings>
                    <CommandBinding Command="{x:Static oui:GalleryElement.Expand}" Executed="onOpen2"></CommandBinding>
                </ScrollViewer.CommandBindings>
                <ItemsPresenter></ItemsPresenter>
            </ScrollViewer>
        </Grid>
    </ControlTemplate>
    <Style TargetType="{x:Type Border}" x:Key="roundBorder">
        <Setter Property="CornerRadius" Value="2"/>
    </Style>



    <ControlTemplate x:Key="collapsedTemplate" TargetType="{x:Type oui:Gallery}">
        <Border x:Name="ClassicBorder" Style="{StaticResource roundBorder}"  Background="{TemplateBinding Background}"
            BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
                HorizontalAlignment="{TemplateBinding HorizontalAlignment}">
            <Grid MouseDown="Grid_MouseDown" TextElement.Foreground="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}" >
                <Grid.CommandBindings>
                    <CommandBinding Command="{x:Static oui:GalleryElement.Expand}" Executed="onOpen3"></CommandBinding>
                </Grid.CommandBindings>
                <Rectangle Fill="Transparent" />
              <!--  <Rectangle  x:Name="lightRect"  Fill="{DynamicResource {x:Static oui:OfficeBrushes.ApplicationMenuButtonPressedBackgroundKey}}" Visibility="Hidden"/> -->
               <!-- <Internals:HeaderPresenterControl Header="{TemplateBinding Header}" Icon="{TemplateBinding Icon}"></Internals:HeaderPresenterControl> -->
                <DockPanel x:Name="ContentPanel" Margin="{TemplateBinding Padding}" >
                    <Button Command="{x:Static oui:GalleryElement.Expand}" DockPanel.Dock="Top" >
                        <Button.Template>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Grid Background="Transparent" >
                                    <ContentPresenter TextElement.Foreground="Red"></ContentPresenter>
                                </Grid>
                            </ControlTemplate>
                        </Button.Template>
                        <Internals:HeaderPresenterControl Tag="2" Header="{TemplateBinding Header}"
                                                          Icon="{TemplateBinding Icon}"
                                                          x:Name="PART_Header"
                                                          TextElement.Foreground="{TemplateBinding TextElement.Foreground}"/>

                    </Button>
                    <Popup Name="PART_Popup" Loaded="onLoaded" Closed="popup_Closed" StaysOpen="False" Height="{TemplateBinding DropDownHeight}" Width="{TemplateBinding DropDownWidth}" IsOpen="{TemplateBinding IsOpen}"
                   AllowsTransparency="True" KeyDown="onPopupKeyDown">
                        <DockPanel>
                            <DockPanel DockPanel.Dock="Bottom">
                                <Thumb DockPanel.Dock="Right"  Style ="{StaticResource bottomRightThumb}" Tag="{Binding ElementName=PART_Popup}" DragDelta="onDragDelta" Width="10"/>
                                <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{DynamicResource {x:Static oui:OfficeBrushes.ResizeThumbBackgroundKey}}"></Rectangle>
                            </DockPanel>
                            <ScrollViewer Background="White" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
                            <ItemsPresenter></ItemsPresenter>
                        </ScrollViewer>
                            </DockPanel>
                    </Popup>
                </DockPanel>

            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="False">
                <Setter Property="Background" Value="{x:Null}" />
                <Setter Property="BorderBrush" Value="{x:Null}" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.MenuHoverBackgroundKey}}" />
                <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.MenuHoverBorderBrushKey}}" />
                <Setter Property="oui:HighlightElement.IsHighlighted" Value="True" />
            </Trigger>
            <Trigger Property="IsOpen" Value="True">
                <Setter Property="Background"  Value="{DynamicResource {x:Static oui:OfficeBrushes.MenuDownBackgroundKey}}" />
            </Trigger>
            <Trigger Property="oui:RibbonElement.ControlState" Value="Medium">
                <Setter Property="oui:RibbonElement.MaxTextWidth" Value="100000"/>
                <Setter TargetName="PART_Header" Property="oui:RibbonElement.ControlState" Value="Large" />
            </Trigger>
            <Trigger Property="oui:RibbonElement.ControlState" Value="Small">
                <Setter Property="oui:RibbonElement.MaxTextWidth" Value="100000"/>
                <Setter TargetName="PART_Header" Property="oui:RibbonElement.ControlState" Value="Medium" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate TargetType="{x:Type oui:Gallery}" x:Key="expandedTemplate">
        <DockPanel Name="panel" Width="{TemplateBinding ActualWidth}">
            <Popup Loaded="onLoaded" Closed="popup_Closed" StaysOpen="False" Height="{TemplateBinding DropDownHeight}" Width="{TemplateBinding DropDownWidth}" IsOpen="True" Placement="Relative"
                   AllowsTransparency="True" KeyDown="onPopupKeyDown" Name="PART_Popup">
                <DockPanel >
                    <DockPanel DockPanel.Dock="Bottom">
                        <Thumb Style="{StaticResource bottomRightThumb}" Tag="{Binding ElementName=PART_Popup}" DragDelta="onDragDelta"/>
                        <Rectangle Fill="{DynamicResource {x:Static oui:OfficeBrushes.ResizeThumbBackgroundKey}}"></Rectangle>
                    </DockPanel>
                   <ScrollViewer Background="{TemplateBinding Background}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" Loaded="onOpenedLoaded">
                        <ItemsPresenter></ItemsPresenter>
                    </ScrollViewer>
                </DockPanel>

            </Popup>
            <Label Name="button">
            </Label>
        </DockPanel>
    </ControlTemplate>

    <Style TargetType="{x:Type oui:Gallery}">
        <Setter Property="FontFamily" Value="Tahoma" />
        <Setter Property="FontSize" Value="8pt" />
      <!--  <Setter Property="Background" Value="Blue" /> -->
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Panel.Background" Value="White" />
        <Setter Property="Border.BorderBrush" Value="#FF828790" />
        <Setter Property="Border.BorderThickness" Value="1" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="Control.VerticalContentAlignment" Value="Center" />
        <Setter Property="Template" Value="{StaticResource normalTemplate}" />
        <Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <Internals:GalleryPanel IsItemsHost="True" Columns="{Binding RelativeSource={RelativeSource Self}, Path=(oui:GalleryElement.MaxColumns)}"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type oui:GalleryItem}" >
                    <Setter Property="Padding" Value="2"/>
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="Focusable" Value="True"/>
                    <Setter Property="BorderThickness" Value="1"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type oui:GalleryItem}">
                                <Border Background="{TemplateBinding Background}" x:Name="Bd" SnapsToDevicePixels="True"
                BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                Padding="{TemplateBinding Padding}"
                      >
                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" x:Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBackgroundKey}}" TargetName="Bd"/>
                                        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="Bd"/>
                                    </Trigger>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GalleryItemSelectedBackgroundKey}}" TargetName="Bd"/>
                                        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="Bd"/>
                                    </Trigger>
                                    <MultiTrigger>
                                        <MultiTrigger.Conditions>
                                            <Condition Property="IsSelected" Value="True" />
                                            <Condition Property="IsMouseOver" Value="True" />
                                        </MultiTrigger.Conditions>
                                        <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GalleryItemSelectedBackgroundKey}}" TargetName="Bd"/>
                                        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="Bd"/>

                                    </MultiTrigger>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="oui:HighlightElement.IsHighlighted" Value="True"></Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="oui:RibbonElement.SmallGroupStyle">
            <Setter.Value>
                <Style TargetType="{x:Type oui:Gallery}">
                    <Setter Property="oui:RibbonElement.ControlState" Value="Small" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="oui:RibbonElement.LargeGroupStyle">
            <Setter.Value>
                <Style TargetType="{x:Type oui:Gallery}">
                    <Setter Property="oui:RibbonElement.ControlState" Value="Large" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="oui:RibbonElement.MediumGroupStyle">
            <Setter.Value>
                <Style TargetType="{x:Type oui:Gallery}">
                    <Setter Property="oui:RibbonElement.ControlState" Value="Medium" />
                </Style>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsOpen" Value="True">
                <Setter Property="Template" Value="{StaticResource expandedTemplate}" />
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <Internals:GalleryPanel IsItemsHost="True" Columns="0"/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>

            </Trigger>
            <Trigger Property="oui:RibbonElement.ControlState" Value="Large">
                <Setter Property="MaxColumns" Value="2" />
            </Trigger>
            <Trigger Property="oui:RibbonElement.ControlState" Value="Medium">
                <Setter Property="IsCollapsed" Value="True" />
            </Trigger>
            <Trigger Property="oui:RibbonElement.ControlState" Value="Small">
                <Setter Property="IsCollapsed" Value="True" />
                <Setter Property="HorizontalAlignment" Value="Left" />
            </Trigger>
            <Trigger Property="IsCollapsed" Value="True">
                <Setter Property="Template" Value="{StaticResource collapsedTemplate}" />
                <Setter Property="VerticalAlignment" Value="Top"/>
                <Setter Property="Background" Value="Red"></Setter>
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <Internals:GalleryPanel IsItemsHost="True" Columns="0"/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger
                     >
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsCollapsed"  Value="False" />
                    <Condition Property="IsMouseOver"  Value="True" />
                    <Condition Property="IsOpen" Value="False"></Condition>
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GalleryHoverBackgroundKey}}"></Setter>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsCollapsed"  Value="False" />
                    <Condition Property="IsMouseOver"  Value="False" />
                    <Condition Property="IsOpen" Value="False"></Condition>
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.GalleryBackgroundKey}}"></Setter>
            </MultiTrigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>